//
//  PanelController.m
//  Shadeco
//
//  Created by Le Thanh Hai on 9/13/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PanelController.h"
#import "Define.h"


@implementation PanelController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

// Create button panel
-(void)createButton
{
    // Add label company and product
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(260, 0, 60, 19);
    label.backgroundColor = [UIColor blackColor];
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont fontWithName:@"AppleGothic" size:12];
    label.textAlignment = UITextAlignmentCenter;
    label.text = @"JIT";
    [self.view addSubview:label];
    [label release];
    
    label = [[UILabel alloc] init];
    label.frame = CGRectMake(0, 0, 120, 19);
    label.backgroundColor = [UIColor blackColor];
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont fontWithName:@"AppleGothic" size:14];
    label.textAlignment = UITextAlignmentCenter;
    label.text = @"ShaDeco ver1.0";
    [self.view addSubview:label];
    [label release];
    
    /******-frame-******/
    UIButton* frameImage = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    frameImage.frame = CGRectMake(H_CONTROLLER_MAGIN_X, H_CONTROLLER_MAGIN_Y, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [frameImage setBackgroundImage:[UIImage imageNamed:@"Frame.png"] forState:UIControlStateNormal];
    [frameImage setTitle:@"" forState:UIControlStateNormal];
    [frameImage addTarget:self action:@selector(frameSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:frameImage];
    /******-stamp-******/
    UIButton* stamp = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    stamp.frame = CGRectMake(H_CONTROLLER_MAGIN_X + CONTROLLER_WIDTH + CONTROLLER_DEPENDING, H_CONTROLLER_MAGIN_Y, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [stamp setBackgroundImage:[UIImage imageNamed:@"Stamp.png"] forState:UIControlStateNormal];
    [stamp setTitle:@"" forState:UIControlStateNormal];
    [stamp addTarget:self action:@selector(stampSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:stamp];
    /******-pen-******/
    UIButton* pen = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    pen.frame = CGRectMake(H_CONTROLLER_MAGIN_X + CONTROLLER_WIDTH*2 + CONTROLLER_DEPENDING*2, H_CONTROLLER_MAGIN_Y, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [pen setBackgroundImage:[UIImage imageNamed:@"Pen.png"] forState:UIControlStateNormal];
    [pen setTitle:@"" forState:UIControlStateNormal];
    [pen addTarget:self action:@selector(penSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pen];
    /******-text-******/
    UIButton* text = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    text.frame = CGRectMake(H_CONTROLLER_MAGIN_X + CONTROLLER_WIDTH*3 + CONTROLLER_DEPENDING*3, H_CONTROLLER_MAGIN_Y, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [text setBackgroundImage:[UIImage imageNamed:@"Text.png"] forState:UIControlStateNormal];
    [text setTitle:@"" forState:UIControlStateNormal];
    [text addTarget:self action:@selector(textSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:text]; 
    /******-brush-******/
    UIButton* brush = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    brush.frame = CGRectMake(H_CONTROLLER_MAGIN_X + CONTROLLER_WIDTH*4 + CONTROLLER_DEPENDING*4, H_CONTROLLER_MAGIN_Y, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [brush setBackgroundImage:[UIImage imageNamed:@"Brush.png"] forState:UIControlStateNormal];
    [brush setTitle:@"" forState:UIControlStateNormal];
    [brush addTarget:self action:@selector(brushSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view	addSubview:brush]; 

    /******-library-******/
    UIButton* library = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    library.frame = CGRectMake(H_CONTROLLER_MAGIN_X, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [library setBackgroundImage:[UIImage imageNamed:@"Lib.png"] forState:UIControlStateNormal];
    [library setTitle:@"" forState:UIControlStateNormal];
    [library addTarget:self action:@selector(librarySelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:library]; 
    /******-camera-******/
    UIButton* camera = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    camera.frame = CGRectMake(H_CONTROLLER_MAGIN_X+CONTROLLER_WIDTH+CONTROLLER_DEPENDING, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [camera setBackgroundImage:[UIImage imageNamed:@"Kamera.png"] forState:UIControlStateNormal];
    [camera setTitle:@"" forState:UIControlStateNormal];
    [camera addTarget:self action:@selector(cameraSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:camera]; 
    /******-save-******/
    UIButton* save = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    save.frame = CGRectMake(H_CONTROLLER_MAGIN_X+CONTROLLER_WIDTH*2+CONTROLLER_DEPENDING*2, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [save setBackgroundImage:[UIImage imageNamed:@"Save.png"] forState:UIControlStateNormal];
    [save setTitle:@"" forState:UIControlStateNormal];
    [save addTarget:self action:@selector(saveSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:save]; 
    /******-mail-******/
    UIButton* mail = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    mail.frame = CGRectMake(H_CONTROLLER_MAGIN_X+CONTROLLER_WIDTH*3+CONTROLLER_DEPENDING*3, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [mail setBackgroundImage:[UIImage imageNamed:@"Mail.png"] forState:UIControlStateNormal];
    [mail setTitle:@"" forState:UIControlStateNormal];
    [mail addTarget:self action:@selector(mailSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:mail]; 
    /******-none-******/
    UIButton* none = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    none.frame = CGRectMake(H_CONTROLLER_MAGIN_X+CONTROLLER_WIDTH*4+CONTROLLER_DEPENDING*4, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [none setBackgroundImage:[UIImage imageNamed:@"None.png"] forState:UIControlStateNormal];
    [none setTitle:@"" forState:UIControlStateNormal];
    [none addTarget:self action:@selector(noneSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:none]; 
    /******-lang-******/
    UIButton* lang = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    lang.frame = CGRectMake(H_CONTROLLER_MAGIN_X+CONTROLLER_WIDTH*5+CONTROLLER_DEPENDING*5, H_CONTROLLER_MAGIN_Y+CONTROLLER_HEIGHT+CONTROLLER_DEPENDING, CONTROLLER_WIDTH, CONTROLLER_HEIGHT);
    [lang setBackgroundImage:[UIImage imageNamed:@"Lang.png"] forState:UIControlStateNormal];
    [lang setTitle:@"" forState:UIControlStateNormal];
    [lang addTarget:self action:@selector(langSelected:) forControlEvents:UIControlEventTouchUpInside];	
    [self.view addSubview:lang];
    /******************/
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self createButton];
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
